import BusinessConstant from '@/constant/BusinessConstant';
import request from '@/request';
import { ComplaintEntity } from '@/entities/ComplaintEntity';

const PREFIX = BusinessConstant.ROOT_SERVER + '/complaint';

export default class ComplaintApi {
  /**
   * 添加投诉记录
   * @param data
   */
  static addComplaint(data: ComplaintEntity.IAddComplaint) {
    return request({
      method: 'POST',
      url: `${ PREFIX }`,
      data,
    });
  }

  /**
   * 通过id获取投诉信息
   * @param complaintId
   * @param identity
   */
  static getComplaint(complaintId: number, identity: number) {
    return request({
      method: 'GET',
      url: `${ PREFIX }?complaintId=${ complaintId }&identity=${ identity }`
    });
  }

  /**
   * 通过房东id获取投诉信息
   * @param landlordId
   */
  static getComplaintByLandlordId(landlordId: number) {
    return request({
      method: 'GET',
      url: `${ PREFIX }/landlord?landlordId=${ landlordId }`
    });
  }

  /**
   * 更新投诉状态
   * @param complaintId 投诉id
   * @param status 状态
   */
  static updateComplaintStatus(complaintId: number, status: number) {
    return request({
      method: 'PUT',
      url: PREFIX,
      data: {
        complaintId,
        status,
      }
    });
  }
}